<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>pushStack例子</title>
    <script type="text/javascript" src="../../js/jquery.js"></script>
</head>
<body>

<div id="grandparent">
    I am grandparent.
    <div id="parent">
        I am parent.
        <div id="child">
            I am child.
        </div>
    </div>
</div>
<script>
   /* var els = $('#child').parent().parent();
    console.dir(els);*/


    $.fn.grandparent = function() {
        return this.parent().parent();
    };

    // var grandparent = $('#child').grandparent().end(); //jQuery-[div#parent]
    var grandparent = $('#child').grandparent(); //jQuery-[div#parent]
console.log(grandparent);


/*   $.fn.grandparent = function() {
       var els = this.parent().parent();
       return this.pushStack(els.get());
   };

   var grandparent = $('#child').grandparent()/!* jquery-[div#grandparent]*!/.end(); /!*jquery-[div#child]*!/
   console.log(grandparent);*/

</script>

</body>
</html>